package org.xymtop.tbdemo.controller;


import cn.hutool.json.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xymtop.tbdemo.common.Result;
import org.xymtop.tbdemo.xmqtt.client.XmqttClient;
import org.xymtop.tbdemo.xmqtt.entity.QosEnum;

@RestController
@RequestMapping("/demo")
@Tag(name = "DemoController", description = "DemoController")
public class DemoController {

    @Autowired
    private XmqttClient xmqttClient;

        @RequestMapping("/hello/{msg}")
        @Operation(summary = "hello", description = "hello")
        public Object hello(@PathVariable String msg){
            xmqttClient.publish("testtopic/1",msg+System.currentTimeMillis(), QosEnum.Qos0,true);
            return Result.success(msg);
        }
}
